#include <QFile>
#include <QTextStream>
#include "track_process.h"

#include "../data_files/constant_variable.h"

Track_process::Track_process(QObject *parent)
    : QObject(parent)
{
}

Track_process::~Track_process()
{
}

QMap<QString, QString>* Track_process::get_track_data(QString content)
{
    QMap<QString, QString>* map(new QMap<QString, QString> ());

    QString data_time(content.mid(0, 8));
    map->insert(TIME.trimmed(), data_time.trimmed());

    QStringList list = content.mid(11).split(",");
    QStringList key_value_group;

    QStringList::Iterator iter;

    // 将数据进行处理，保存到track_data_map_中
    for (iter = list.begin(); list.end() != iter; ++iter) {
        key_value_group = iter->split("=");

        if (2 == key_value_group.count()) {
            if (key_value_group[1].isEmpty()) {
                key_value_group[1] = "None";
            }

            // 将key/value保存到QMap中，去除数据的空格。将航班号的方括号去除
            map->insert(key_value_group[0].trimmed(),
                    key_value_group[1].trimmed().replace("[", "").replace("]", ""));
        }
    }

    return map;
    //    emit si_send_track_data_for_map(map);
}
